.org 0xC31EC ; Counterattack First

Counter_First:

	PUSH 	{R4, LR}
	
	LDR 	R2, [Counter_First_1]
	LDR 	R1, [Counter_First_2]
	LDR 	R3, [R2, 0]
	LDR 	R2, [R1, 0]
	
	MOV		R1, 0x98
	ADD 	R2, R3, R2, LSL 2		
	LDR 	R2, [R2, 0x48]
	MUL		R4, R0, R1
	ADD 	R0, R2, 0x5000
	LDR 	R0, [R0, 0xA58]	
	ADD 	R0, R0, R4
	ADD 	R0, R0, 0x74
	
	MOV 	R1, CO_First_Counters				; Skill: First Counters
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped	
	CMP 	R0, 0								; Does CO use that skill?
	BNE		First_Counters_Attached
		
;-------------------------------------------------------------------------------	

	BL		Skill_Power_Check
	
	CMP		R0, Power_SCOP						; Has SCOP been activated?
	BNE		No_First_Counters
	
	ADD 	R0, R1, 0x74
	
	MOV 	R1, Rank_Mistwalker					; Rank: Mistwalker
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped	
	CMP 	R0, 0								; Does CO use that skill?
	BEQ		No_First_Counters
	
;-------------------------------------------------------------------------------	

First_Counters_Attached:	

	MOV		R0, 1								; You can counterattack first
	POP 	{R4, LR}
	BX 		LR	
	
;-------------------------------------------------------------------------------	
	
No_First_Counters:
	
	MOV		R0, 0								; You can't counterattack first
	POP 	{R4, LR}	
	BX		LR	

;-------------------------------------------------------------------------------	

	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP

Counter_First_1:
	.dw Reg1_Skill
	
Counter_First_2:
	.dw Reg2_Skill


